import time

def sorted(data):
    flag = True
    k = 1
    while flag:
        flag = False

        for i in range(len(data) - k - 1):
            if data[i] > data[i + 1]:
                data[i], data[i + 1] = data[i + 1], data[i]
                flag = True
        k += 1

def read(file):
    file_open = open(file, "r")
    data = file_open.readlines()
    return data

text1 = read("m1_sorted.txt")
text2 = read("m2_reverse.txt")
text3 = read("m3_shuffle.txt")

t_start1 = time.time()
sorted(text1)
t_finish1 = time.time()
print("m1_sorted", round(t_finish1 - t_start1)*1000, "milliseconds")

t_start2 = time.time()
sorted(text2)
t_finish2 = time.time()
print("m2_reverse", round((t_finish2 - t_start2)*1000), "milliseconds")

t_start3 = time.time()
sorted(text3)
t_finish3 = time.time()
print("m3_shuffle", round((t_finish3 - t_start3)*1000), "milliseconds")
